<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    {{include '../shared/_common_top'}}
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>分类信息管理</h5>
                    </div>
                    <div class="ibox-content">
                        <div class="row">
                            <div class="col-sm-10">
                                <form class="form-inline">
                                    <div class="form-group">
                                        <label>分类名字</label>
                                        <input type="text" class="form-control" name="name" value="{{query.name}}" placeholder="请输入分类名字进行查找">
                                    </div>
                                    <button type="submit" class="btn btn-primary fa fa-search">查询</button>
                                </form>
                            </div>
                            <div class="col-sm-2">
                                <div class="">
                                    <a href="/admin/book_type/add" class="btn btn-danger">添加</a>
                                </div>
                            </div>
                        </div>
                        <table class="table table-striped table-bordered table-hover">
                            <thead>
                                <tr>
                                    <th>序号</th>
                                    <th>分类名字</th>
                                    <th>编码</th>
                                    <th>链接</th>
                                    <th>数量</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                {{each list}}
                                <tr>
                                    <td>{{$index+1}}</td>
                                    <td>{{$value.name}}</td>
                                    <td>{{$value.code}}</td>
                                    <td>{{$value.url}}</td>
                                    <td>{{$value.page_count}}</td>
                                    <td>
                                        <i onclick='dalDel("{{$value.id}}")' class="btn btn-sm btn-default fa fa-trash"></i>
                                        <!-- fontawesome字体图标
									http://fontawesome.io/
								 -->
                                        <a href="/admin/book_type/edit/{{$value.id}}"><i class="fa fa-pencil btn btn-sm btn-default"></i></a>
                                    </td>
                                </tr>
                                {{/each}}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    </div>
    <!-- 在页面上创建一个隐藏的表单做删除时使用 -->
    <form action="/admin/book_type/del" id="delForm" method="post">
        <input type="hidden" name="id" id="delID">
    </form>
	{{include '../shared/_common_bottom'}}
    <script>
    function dalDel(id) {
        // 通过confirm弹出提示
        if (confirm('是否确认删除此项?')) {
            // alert(id)
            // 可以通过ajax实现删除
            // $.ajax(...
            $('#delID').val(id)
            $('#delForm').submit() //触发表单提交事件
        }
    }
    </script>
</body>

</html>
